/**
 * 
 */
package net.sisgac.despacho_mercaderia.model.dao.jpa;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.NoResultException;
import javax.persistence.Persistence;
import javax.persistence.Query;

import net.sisgac.despacho_mercaderia.model.OrdenServicio;
import net.sisgac.despacho_mercaderia.model.Transportista;
import net.sisgac.despacho_mercaderia.model.dao.OrdenServicioDAO;

/**
 * @author Luis Yarleque
 *
 */
@SuppressWarnings("unchecked")
public class JPAOrdenServicioDAO implements OrdenServicioDAO{

	private EntityManager em;
	
	public JPAOrdenServicioDAO(EntityManager em){
		this.em=em;
	}
	

	
	@Override
	public OrdenServicio findBlyId(int id) {
		return em.find(OrdenServicio.class, id);
	}

	

   public int insert(OrdenServicio ordenSevicioDTO) {
	  try {
			em.getTransaction().begin();
			em.persist(ordenSevicioDTO);
			em.flush();
			em.getTransaction().commit();

		} finally {
			em.close();
			return 1;
		}
	}

}
